/**
 * Copyright (c) 2006-2009 by Shanghai UnuTrip Network Technology Development Co.,Ltd
 * All rights reserved.
 */


package com.unusap.remote.core.remote.httpinvoker;

import java.io.IOException;
import java.net.HttpURLConnection;

import org.springframework.remoting.httpinvoker.SimpleHttpInvokerRequestExecutor;

import com.unusap.remote.core.remote.factory.HttpHeadersProvider;
import com.unusap.remote.core.remote.http.CommonHttpConnectionArguments;
import com.unusap.remote.core.util.URLConnectionPropertyUtils;

/**
 * 
 * @author danson
 * HttpHeaderSupportSimpleHttpInvokerRequestExecutor.java
 * 2009-9-4
 */
public class HttpHeaderSupportSimpleHttpInvokerRequestExecutor extends SimpleHttpInvokerRequestExecutor {
	
	private CommonHttpConnectionArguments connectionArguments = new CommonHttpConnectionArguments();

	private HttpHeadersProvider httpHeadersProvider;

	public HttpHeaderSupportSimpleHttpInvokerRequestExecutor(HttpHeadersProvider httpHeadersProvider) {
		this.httpHeadersProvider = httpHeadersProvider;
	}
	
	@Override
	protected void prepareConnection(HttpURLConnection con, int contentLength)
			throws IOException {
		super.prepareConnection(con, contentLength);
		URLConnectionPropertyUtils.setProperty(con, httpHeadersProvider, connectionArguments);
	}

	public void setConnectTimeout(int connectTimeout) {
    	connectionArguments.setConnectTimeout(connectTimeout);
    }

    public void setUser(String user) {
    	connectionArguments.setUser(user);
    }

    public void setPassword(String password) {
    	connectionArguments.setPassword(password);
    }
    
}
